package com.example.vuebackend.service;

import com.example.vuebackend.dto.Person;
import com.example.vuebackend.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class PersonService{

    @Autowired
    private PersonRepository personRepository;

    public Page<Person> findAll(PageRequest request) {
        return personRepository.findAll(request);
    }

    public Person findById(Integer id) {
        return personRepository.findById(id).get();
    }

    public Person save(Person person) {
        return personRepository.save(person);
    }

    public void deleteById(Integer id) {
        personRepository.deleteById(id);
    }
}
